package com.aaa.mrcai.service.impl;

import com.aaa.mrcai.mapper.BusinessOrderMapper;
import com.aaa.mrcai.pojo.entity.AdminOrder;
import com.aaa.mrcai.pojo.entity.UserInfo;
import com.aaa.mrcai.query.AdminOrderQuery;
import com.aaa.mrcai.result.AjaxResult;
import com.aaa.mrcai.service.BusinessOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.ServletContext;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ Author: Lining
 * @ Date: 2021/12/15 19:01
 */
@Service
public class BusinessOrderServiceImpl implements BusinessOrderService {

    @Autowired
    private BusinessOrderMapper businessOrderMapper;

    @Autowired
    private ServletContext servletContext;

    @Override
        public AjaxResult list(AdminOrderQuery adminOrderQuery) {

        UserInfo user = (UserInfo) servletContext.getAttribute("user");
        System.out.println("uuuuuu"+user);
        Integer bid = user.getUserLogin().getBid();
        adminOrderQuery.setId(bid);
        System.out.println("aaaaaaa"+adminOrderQuery);
        List<AdminOrder> list = businessOrderMapper.list(adminOrderQuery);
            Long aLong = businessOrderMapper.getBusinessOrderTotal(adminOrderQuery);
            Map<String, Object> map = new HashMap<>();
            map.put("currentPageData",list);
            map.put("currentDataTotal",aLong);
            return AjaxResult.success(map);
        }
}
